package com.fooddiary.web.form;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class EatingForm extends BaseForm implements Comparable<EatingForm>{

	private List<String> errors = new ArrayList<String>();

	private Integer weightId;
	private Integer eatingTypeId;
	private EatingTypeForm eatingType;
	
	private String time;
	private String food;
	private Boolean overweight;
	
	/**
	 * Returns list of errors<br>
	 * @return {@link List<String>};
	 */
	public List<String> getErrors() {
		return errors;
	}
	
	/**
	 * Sets list of errors <br>
	 * @param p_errors - {@link List<String>};
	 */
	public void setErrors(List<String> p_errors) {
		errors = p_errors;
	}
	
	/**
	 * Returns eating type form <br>
	 * @return {@link EatingTypem};
	 */
	public EatingTypeForm getEatingType() {
		return eatingType;
	}

	/**
	 * Sets eating type form <br>
	 * @param p_eatingTypeForm - {@link EatingType};
	 */
	public void setEatingType(EatingTypeForm p_eatingType) {
		eatingType = p_eatingType;
	}

	/**
	 * Returns time of eating <br>
	 * @return {@link String};
	 */
	public String getTime() {
		return time;
	}
	
	/**
	 * Sets time of eating <br>
	 * @param p_time - {@link String};
	 */
	public void setTime(String p_time) {
		time = p_time;
	}
	
	/**
	 * Returns food description <br>
	 * @return {@link String};
	 */
	public String getFood() {
		return food;
	}
	
	/**
	 * Sets food description <br>
	 * @param p_food - {@link String};
	 */
	public void setFood(String p_food) {
		food = p_food;
	}
	
	/**
	 * Returns overweight flag <br>
	 * @return {@link Boolean};
	 */
	public Boolean getOverweight() {
		return overweight;
	}
	
	/**
	 * Sets oveweight flag <br>
	 * @param p_overweight - {@link Boolean};
	 */
	public void setOverweight(Boolean p_overweight) {
		overweight = p_overweight;
	}
	
	/**
	 * Returns unique id for selectrd eatingType <br>
	 * @return {@link Integer};
	 */
	public Integer getEatingTypeId() {
		return eatingTypeId;
	}

	/**
	 * Sets unique id for selected eating type <br>
	 * @param p_eatingTypeId - {@link Integer};
	 */
	public void setEatingTypeId(Integer p_eatingTypeId) {
		eatingTypeId = p_eatingTypeId;
	}

	/**
	 * Returns id of parent weight <br>
	 * @return {@link Integer};
	 */
	public Integer getWeightId() {
		return weightId;
	}

	/**
	 * Sets id of parent weight <br>
	 * @param p_weightId - {@link Integer};
	 */
	public void setWeightId(Integer p_weightId) {
		weightId = p_weightId;
	}

	@Override
	public int compareTo(EatingForm p_form) {
		if(p_form.getEatingType()!=null){
			if(p_form.getEatingType().getOrder() > getEatingType().getOrder()){
				return -1;
			}else if(p_form.getEatingType().getOrder() < getEatingType().getOrder()){
				return 1;
			}else{
				return 0;
			}
		}else{
			return 1;
		}
	}
	
}
